
:: Disable messages
@echo off

:: Define filenames
set "asmfile=ff6_bank_c3j_opti.asm"
set "romfile=ff6j.smc"

:: Enable messages
@echo on

:: Convert characters between pipes to data bytes
bin\awk -F "|" -f bin\charset.awk %asmfile% > c3j_tmp1.asm

:: Remove leading commas ("db  ," -> "db ")
bin\awk "{ gsub(/db  ,/,\"db \") } 1" c3j_tmp1.asm > c3j_tmp2.asm

:: Convert encoding from UTF-8 to ANSI
bin\iconv -c -f UTF-8 -t WINDOWS-1252 c3j_tmp2.asm > c3j_tmp1.asm

:: Compile via asar
bin\asar c3j_tmp1.asm %romfile%

:: Delete temporary files
del c3j_tmp1.asm
del c3j_tmp2.asm

:: Wait for keypress
@pause